home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK2.toast / Development Kits (Disc 2) / QuickTime / Programming Stuff / Documentation / develop articles / develop Issue 17 / MultipleMovies / MyMultipleMoviesApp ƒ / MyApplication.c < prev    next >
Encoding:
Text File  |  1997-02-26  |  17.5 KB  |  705 lines  |  [TEXT/KAHL]

  1. //--------------------------------------------------------------------------
  2. //
  3. //        MyMultipleMovieApp.
  4. //            by John Wang
  5. //
  6. //        Description:    QuickTime Multiple Movie Application.
  7. //
  8. //        Version:    1.0        11/09/93    Completed for develop column.
  9. //
  10. //
  11. //--------------------------------------------------------------------------
  12.  
  13. //    #includes:
  14.  
  15. #include    <GestaltEqu.h>
  16. #include    <Script.h>
  17. #include    <ToolUtils.h>
  18.  
  19. #include    "MyApplication.h"
  20. #include    "BetterFlattenMovie.h"
  21.  
  22. //--------------------------------------------------------------------------
  23.  
  24. //    Globals:
  25.  
  26. //    These globals are used by the shell and must be defined:
  27.  
  28. long        gQDfeature, gWindowCount;
  29. Str255        gMyAboutTitle = "\PQuickTime Application";
  30. Str255        gMyAboutDesc = "\PThis is a multiple movie playback app.";
  31.  
  32. struct WindowInfo {
  33.     //    Document info.
  34.     FSSpec            theFSSpec;        //    FSSpec for document.
  35.     short            refNum;            //    refNum for document.
  36.     
  37.     //    Current movie playing info.
  38.     Movie            theMovie;        //    Current movie.  nil if none.
  39.     MovieController    theMC;            //    Current movie controller.  nil if none.
  40.     Str255            moviename;        //    Name of movie if exists.
  41.     short            resId;            //    resource id of movie in document. -1 if no resId.
  42.     long            movieOffset;    //    offset to movie resource atom in data fork.  -1 if no offset.
  43. };
  44. typedef        struct WindowInfo WindowInfo, *WindowInfoPtr, **WindowInfoHandle;
  45.  
  46. //--------------------------------------------------------------------------
  47.  
  48. //    MyInitialize:
  49.  
  50. //    is called at init time after the toolbox is initialized.  This routine is
  51. //    called only once.
  52.  
  53. OSErr MyInitialize()
  54. {
  55.     OSErr        err;
  56.  
  57.     //    We require QuickTime so make sure it is available.
  58.     if (err = Gestalt(gestaltQuickTime, &gQDfeature))
  59.         return(err);
  60.  
  61.     if (err = EnterMovies())
  62.         return(err);
  63.         
  64.     return(noErr);
  65. }
  66.  
  67. //--------------------------------------------------------------------------
  68.  
  69. //    MyEvent:
  70.  
  71. //    This routine is called for each window for an event.
  72.  
  73. Boolean MyEvent(WindowPtr theWindow, EventRecord *myEvent)
  74. {
  75.     WindowInfoHandle    myWinfo;
  76.     Boolean                ret;
  77.     
  78.     ret = FALSE;
  79.     myWinfo = (WindowInfoHandle) GetWRefCon(theWindow);
  80.     if ((**myWinfo).theMC != nil) {
  81.         ret = MCIsPlayerEvent((**myWinfo).theMC, myEvent);
  82.     }
  83.     
  84.     return(ret);
  85. }
  86.  
  87. //--------------------------------------------------------------------------
  88.  
  89. //    MyIdle:
  90.  
  91. //    Depending on the value of the constant MYIDLEDEF, this routine may have different
  92. //    calling frequency.
  93. //    If MYIDLEDEF == 2, then this routine gets called for every
  94. //       window owned by the application of type MAS_WINDOWDOC per iteration of
  95. //       the event loop.  You can assume that the port and gdevice are set to the window.
  96. //    If MYIDLEDEF == 1, then this routine gets called once per event loop.  theWindow will be nil.
  97. //    If MYIDLEDEF == 0, this routine never gets called.
  98.  
  99. void MyIdle(WindowPtr theWindow)
  100. {
  101.     WindowInfoHandle    myWinfo;
  102.     
  103.     myWinfo = (WindowInfoHandle) GetWRefCon(theWindow);
  104.     if ((**myWinfo).theMC != nil) {
  105.         MCIdle((**myWinfo).theMC);
  106.     }
  107. }
  108.  
  109. //--------------------------------------------------------------------------
  110.  
  111. //    MyDraw:
  112.  
  113. //    is called when redrawing the window is needed.  The port and gdevice
  114. //    is already set and begin and end update are called for MyDraw.
  115.  
  116. void MyDraw(WindowPtr theWindow)
  117. {
  118.     //    Erase a black background for movie.
  119.     PaintRect(&(theWindow->portRect));
  120. }
  121.  
  122. //--------------------------------------------------------------------------
  123.  
  124. //    MyFinishup:
  125.  
  126. //    This routine gets called once when the application is quitting.
  127. //    This gives the app the chance to clean up.
  128.  
  129. void MyFinishup()
  130. {
  131.     //    As discussed in issue #13 of 'develop' magazine, it is better to let QuickTime
  132.     //    call ExitMovies().
  133. }
  134.  
  135. //--------------------------------------------------------------------------
  136.  
  137. //    MyYieldTime:
  138.  
  139. //    This routine is called whenever the app receives a suspend or resume event.  This
  140. //    allows the yield time (passed to WaitNextEvent) to be changed.  I.e., if you don't
  141. //    do much processing the in background, you should set the yield to a high value
  142. //    when the suspend message is received.
  143.  
  144. long MyYieldTime(long message)
  145. {
  146.     if (message)
  147.         //    Resume message
  148.         return(0);
  149.     else
  150.         //    Suspend message
  151.         return(30);
  152. }
  153.  
  154. //--------------------------------------------------------------------------
  155.  
  156. //    MyDoCommand:
  157.  
  158. //    If the shell's doCommand routine can not process the menu selection, then this routine is
  159. //    called.  Do not call HiliteMenu because it is called by the shell.
  160. //    If the command can not be handled, this it must be an error and the shell will
  161. //    present a FATAL error to the user.
  162.  
  163. OSErr MyDoCommand(short theMenu, short theItem)
  164. {
  165.     WindowPtr                frontWindow;
  166.     WindowInfoHandle        myWinfo;
  167.     
  168.     switch (theMenu) {
  169.         case MENU_COLLECTION:
  170.             if (IsMyWindow(frontWindow = FrontWindow())) {
  171.                 myWinfo = (WindowInfoHandle) GetWRefCon(frontWindow);
  172.                 switch (theItem) {
  173.                     case MENU_MACADDRESATOM:
  174.                         Mac_AddMovieResAtom(&((**myWinfo).refNum), &((**myWinfo).theFSSpec));
  175.                         break;
  176.                     case MENU_MACADDALL:
  177.                         Mac_AddMovieAll(&((**myWinfo).refNum), &((**myWinfo).theFSSpec));
  178.                         break;
  179.                     case MENU_CROSSADDALL:
  180.                         Cross_AddMovieAll(&((**myWinfo).refNum), &((**myWinfo).theFSSpec));
  181.                         break;
  182.                     case MENU_BOTHADDALL:
  183.                         Both_AddMovieAll(&((**myWinfo).refNum), &((**myWinfo).theFSSpec));
  184.                         break;
  185.                     default:
  186.                         return(theItem);
  187.                 }
  188.                 adjustMoviesMenu(frontWindow);
  189.             } else
  190.                 SysBeep(50);
  191.             break;
  192.             
  193.         case MENU_MOVIES:
  194.             if (IsMyWindow(frontWindow = FrontWindow()))
  195.                 SelectThisMovie(theItem);
  196.             else
  197.                 SysBeep(50);
  198.             break;
  199.             
  200.         default:
  201.             return(theItem);
  202.     }
  203.     
  204.     return(noErr);
  205. }
  206.  
  207. //--------------------------------------------------------------------------
  208.  
  209. //    MyDoKeyDown:
  210.  
  211. void        MyDoKeyDown(EventRecord *myEvent)
  212. {
  213. }
  214.  
  215. //--------------------------------------------------------------------------
  216.  
  217. //    If the shell receives a inContent mouse down, or zoom window mouse down,
  218. //    the following routines may be called (MyInContent, MyActivateEvent, MyZoomWindow, MyAdjustMenus) :
  219.  
  220. void MyInContent(WindowPtr foundWindow, Point where)
  221. {
  222. }
  223.  
  224. void MyZoomWindow(WindowPtr foundWindow, Boolean zoomOut)
  225. {
  226. }
  227.  
  228. void MyAdjustMenus()
  229. {
  230. }
  231.  
  232. //--------------------------------------------------------------------------
  233.  
  234. //    MyNew and MyOpen:
  235.  
  236. WindowPtr createMoviesWindow(FSSpec *movieFSSpec, short theRefNum);
  237. WindowPtr createMoviesWindow(FSSpec *movieFSSpec, short theRefNum)
  238. {
  239.     WindowPtr                myWindow;
  240.     WindowInfoHandle        myWinfo;
  241.     Rect                    windowRect;
  242.     GDHandle                myMaxDevice;
  243.  
  244.     //    Create window.
  245.     myMaxDevice = GetMaxDevice(&((**GrayRgn).rgnBBox));
  246.     windowRect = (**((**myMaxDevice).gdPMap)).bounds;
  247.     myWindow = NewCWindow(0L, &windowRect, (*movieFSSpec).name, 1, noGrowDocProc, (WindowPtr) -1, TRUE, 0L);
  248.     OffsetRect(&windowRect, -windowRect.left, -windowRect.top);
  249.     SetMyWindow(myWindow);
  250.     SetGWorld((CGrafPtr) myWindow, GetMainDevice());
  251.     
  252.     //    This handle must be locked because we dereference it all the time.
  253.     myWinfo = (WindowInfoHandle) NewHandle(sizeof(WindowInfo));
  254.     MoveHHi((Handle) myWinfo);
  255.     HLock((Handle) myWinfo);
  256.     SetWRefCon(myWindow, (long) myWinfo);
  257.     
  258.     (**myWinfo).theFSSpec = *movieFSSpec;
  259.     (**myWinfo).refNum = theRefNum;
  260.     (**myWinfo).theMovie = nil;
  261.     (**myWinfo).theMC = nil;
  262.     (**myWinfo).moviename[0] = 0;
  263.     (**myWinfo).resId = -1;
  264.     (**myWinfo).movieOffset = -1;
  265.     
  266.     return(myWindow);
  267. }
  268.  
  269. void MyNew()
  270. {
  271.     WindowPtr                myWindow;
  272.     StandardFileReply        reply;
  273.     short                    myRefNum;
  274.     MenuHandle                myMenu;
  275.     
  276.     if (gWindowCount > 0) {
  277.         SysBeep(50);
  278.         return;
  279.     }
  280.     
  281.     //    Ask for a new document file.  If none given, then quit.
  282.     StandardPutFile("\PNew document", "\PMovie Collection", &reply);
  283.     if (!reply.sfGood)
  284.         return;
  285.  
  286.     //    Use QuickTime to create movie file.
  287.     if (CreateMovieFile(&reply.sfFile, 'WnG1', smSystemScript,
  288.             createMovieFileDeleteCurFile | createMovieFileDontCreateMovie, &myRefNum, nil)) {
  289.         Alert(ALERT_CANTNEW, nil);
  290.         return;
  291.     }
  292.     
  293.     myWindow = createMoviesWindow(&(reply.sfFile), myRefNum);
  294.     gWindowCount += 1;
  295.     
  296.     //    Add new menu.
  297.     adjustMoviesMenu(myWindow);
  298. }
  299.  
  300. //    If theFSS is not nil, then the file to be opened is specified in the FSSpec.
  301. void MyOpen(FSSpec *theFSS)
  302. {
  303.     OSErr                    err;
  304.     WindowPtr                myWindow;
  305.     StandardFileReply        reply;
  306.     FSSpec                    myFSSpec;
  307.     SFTypeList                types;
  308.     short                    myRefNum;
  309.     MenuHandle                myMenu;
  310.  
  311.     if (gWindowCount > 0) {
  312.         SysBeep(50);
  313.         return;
  314.     }
  315.     
  316.     //    If theFSS was nil, then open a file manually.
  317.     if (theFSS == nil) {
  318.         types[0] = 'MooV';
  319.         StandardGetFilePreview(nil, 1, types, &reply);
  320.         if (!reply.sfGood)
  321.             return;
  322.         myFSSpec = reply.sfFile;
  323.     } else {
  324.         myFSSpec = *theFSS;
  325.     }
  326.  
  327.     //    Open movie file.
  328.     err = OpenMovieFile(&myFSSpec, &myRefNum, fsRdWrPerm);
  329.     if (myRefNum == -1 || err) {
  330.         Alert(ALERT_ERROROPEN, nil);
  331.         return;
  332.     }
  333.     
  334.     myWindow = createMoviesWindow(&myFSSpec, myRefNum);
  335.     gWindowCount += 1;
  336.  
  337.     //    Add new menu.
  338.     adjustMoviesMenu(myWindow);
  339. }
  340.  
  341. //--------------------------------------------------------------------------
  342.  
  343. //    MyClose:
  344.  
  345. void MyClose()
  346. {
  347.     WindowPtr            closeWindow;
  348.     WindowInfoHandle    myWinfo;
  349.     MenuHandle            myMenu;
  350.     
  351.     if ((closeWindow = FrontWindow()) == nil)
  352.         return;
  353.         
  354.     if (IsMyWindow(closeWindow)) {
  355.         myWinfo = (WindowInfoHandle) GetWRefCon(closeWindow);
  356.  
  357.         if ((**myWinfo).theMC != nil)
  358.             DisposeMovieController((**myWinfo).theMC);
  359.         if ((**myWinfo).theMovie != nil);
  360.             DisposeMovie((**myWinfo).theMovie);
  361.         if ((**myWinfo).refNum != -1)
  362.             CloseMovieFile((**myWinfo).refNum);
  363.         DisposHandle((Handle) myWinfo);
  364.         DisposeWindow(closeWindow);
  365.         gWindowCount -= 1;
  366.         
  367.         //    Delete old menu.
  368.         adjustMoviesMenu(nil);
  369.         CompactMem(0xfffffff);
  370.     }
  371. }
  372.  
  373. //--------------------------------------------------------------------------
  374.  
  375. //    MySave, MySaveAs, MyPageSetup, MyPrint, MyUndo, MyCut, MyCopy,
  376. //    MyPaste, MyClear, and MySelectAll: are not implemented.
  377.  
  378. void MySave()
  379. {
  380.     SysBeep(50);
  381. }
  382.  
  383. void MySaveAs()
  384. {
  385.     SysBeep(50);
  386. }
  387.  
  388. void MyPageSetup()
  389. {
  390.     SysBeep(50);
  391. }
  392.  
  393. void MyPrint()
  394. {
  395.     SysBeep(50);
  396. }
  397.  
  398. void MyUndo(void)
  399. {
  400.     SysBeep(50);
  401. }
  402.  
  403. void MyCut(void)
  404. {
  405.     SysBeep(50);
  406. }
  407.  
  408. void MyCopy(void)
  409. {
  410.     SysBeep(50);
  411. }
  412.  
  413. void MyPaste(void)
  414. {
  415.     SysBeep(50);
  416. }
  417.  
  418. void MyClear(void)
  419. {
  420.     SysBeep(50);
  421. }
  422.  
  423. void MySelectAll(void)
  424. {
  425. }
  426.  
  427.  
  428. //--------------------------------------------------------------------------
  429.  
  430. //    Utility routines (IsMyWindow, SetMyWindow, IsMyClipWindow, SetMyClipWindow):
  431.  
  432. //    Called to determine if the window is owned by app.
  433. Boolean IsMyWindow(WindowPtr theWindow)
  434. {
  435.     if (theWindow)
  436.         return(((CWindowPeek) theWindow)->windowKind == MAS_WINDOWDOC);
  437.     else
  438.         return(FALSE);
  439. }
  440.  
  441. //    Called to set the window's creator.
  442. void SetMyWindow(WindowPtr theWindow)
  443. {
  444.     if (theWindow)
  445.         ((CWindowPeek) theWindow)->windowKind = MAS_WINDOWDOC;
  446. }
  447.  
  448. //    Called to determine if window is a show clipboard window.
  449. Boolean IsMyClipWindow(WindowPtr theWindow)
  450. {
  451.     if (theWindow)
  452.         return(((CWindowPeek) theWindow)->windowKind == MAS_WINDOWCLIP);
  453.     else
  454.         return(FALSE);
  455. }
  456.  
  457. //    Called to set the creator as the window clip.
  458. void SetMyClipWindow(WindowPtr theWindow)
  459. {
  460.     if (theWindow)
  461.         ((CWindowPeek) theWindow)->windowKind = MAS_WINDOWCLIP;
  462. }
  463.  
  464. //--------------------------------------------------------------------------
  465.  
  466. void adjustMoviesMenu(WindowPtr theWindow)
  467. {
  468.     WindowInfoHandle    myWinfo;
  469.     FSSpec                theFSSpec;
  470.     short                theRefNum;
  471.     MenuHandle            myMenu;
  472.     short                movieCount;
  473.     Handle                movieResource;
  474.     short                movieID;
  475.     ResType                movieType;
  476.     Str255                movieName;
  477.     short                i;
  478.     
  479.     //    Delete old menu if it exists.
  480.     if (myMenu = GetMHandle(MENU_MOVIES)) {
  481.         DeleteMenu(MENU_MOVIES);
  482.         DisposeMenu(myMenu);
  483.     }
  484.  
  485.     //    If a window is passed, then update the menu for it.
  486.     if (IsMyWindow(theWindow)) {
  487.         myWinfo = (WindowInfoHandle) GetWRefCon(theWindow);
  488.         theFSSpec = (**myWinfo).theFSSpec;
  489.         theRefNum = (**myWinfo).refNum;
  490.         myMenu = NewMenu(MENU_MOVIES, theFSSpec.name);
  491.         InsertMenu(myMenu, 0);
  492.         
  493.         //    Add resource fork movies into menu.
  494.         if (theRefNum != -1) {
  495.             movieCount = Count1Resources('moov');
  496.             for (i=1; i<=movieCount; i++) {
  497.                 movieResource = Get1IndResource('moov', i);
  498.                 GetResInfo(movieResource, &movieID, &movieType, movieName);
  499.                 if (movieName[0] == 0) {
  500.                     NumToString(movieID, &movieName[23]);
  501.                     movieName[0] = movieName[23] + 23;
  502.                     BlockMove("Resource Fork Movie ID#", &movieName[1], 23);
  503.                 }
  504.                 AppendMenu(myMenu, movieName);
  505.                 ReleaseResource(movieResource);
  506.             }
  507.         }
  508.         
  509.         //    Add single fork movies into menu.
  510.         if (CountMoviesInDataFork(&theFSSpec, &movieCount) == noErr) {
  511.             for (i=0; i<movieCount; i++) {
  512.                 NumToString(i+1, &movieName[19]);
  513.                 movieName[0] = movieName[19] + 19;
  514.                 BlockMove("Single Fork Movie #", &movieName[1], 19);
  515.                 AppendMenu(myMenu, movieName);
  516.             }
  517.         }
  518.     }
  519.  
  520.     //    Update MenuBar.
  521.     DrawMenuBar();
  522. }
  523.  
  524. void SelectThisMovie(short item)
  525. {
  526.     OSErr                err;
  527.     WindowPtr            frontWindow;
  528.     WindowInfoHandle    myWinfo;
  529.     short                resCount, dataCount;
  530.     Handle                movieResource;
  531.     short                movieID;
  532.     ResType                movieType;
  533.     long                 controllerFlags;
  534.     Rect                movieBounds;
  535.     short                i, xoffset, yoffset;
  536.     Str255                junkStr;
  537.     short                myRefNum;
  538.     Movie                tempMovie;
  539.     short                tempResId;
  540.     long                tempMovieOffset;
  541.     
  542.     if ((frontWindow = FrontWindow()) == nil)
  543.         return;
  544.         
  545.     if (IsMyWindow(frontWindow)) {
  546.         myWinfo = (WindowInfoHandle) GetWRefCon(frontWindow);
  547.  
  548.         //    Get rid of old movie
  549.         if ((**myWinfo).theMC != nil)
  550.             DisposeMovieController((**myWinfo).theMC);
  551.         if ((**myWinfo).theMovie != nil)
  552.             DisposeMovie((**myWinfo).theMovie);
  553.         (**myWinfo).theMovie = nil;
  554.         (**myWinfo).theMC = nil;
  555.         (**myWinfo).moviename[0] = 0;
  556.         (**myWinfo).resId = -1;
  557.         (**myWinfo).movieOffset = -1;
  558.  
  559.         //    Invalidate window.
  560.         InvalRect(&(frontWindow->portRect));
  561.         
  562.         //    Count the number of movies in resource fork and data fork
  563.         resCount = Count1Resources('moov');
  564.         CountMoviesInDataFork(&((**myWinfo).theFSSpec), &dataCount);
  565.  
  566.         //    Find which movie to play.
  567.         if (item <= resCount) {
  568.             movieResource = Get1IndResource('moov', item);
  569.             GetResInfo(movieResource, &tempResId, &movieType, (**myWinfo).moviename);
  570.             ReleaseResource(movieResource);
  571.             err = NewMovieFromFile(&tempMovie, (**myWinfo).refNum, &tempResId, nil,
  572.                                 newMovieActive, (Boolean *) 0);
  573.             (**myWinfo).theMovie = tempMovie;
  574.             (**myWinfo).resId = tempResId;
  575.             if (err) {
  576.                 Alert(ALERT_CANTOPEN, nil);
  577.                 return;
  578.             }
  579.         } else {
  580.             item = item-resCount;
  581.             err = SearchMoviesInDataFork(&((**myWinfo).theFSSpec), item, &tempMovieOffset);
  582.             (**myWinfo).movieOffset = tempMovieOffset;
  583.             if (err) {
  584.                 Alert(ALERT_CANTOPEN, nil);
  585.                 return;
  586.             }
  587.             if (FSpOpenDF(&((**myWinfo).theFSSpec), fsRdPerm, &myRefNum) == noErr) {
  588.                 err = NewMovieFromDataFork(&tempMovie, myRefNum, (**myWinfo).movieOffset, newMovieActive, nil);
  589.                 (**myWinfo).theMovie = tempMovie;
  590.                 FSClose(myRefNum);
  591.                 if (err) {
  592.                     Alert(ALERT_CANTOPEN, nil);
  593.                     return;
  594.                 }
  595.             }
  596.         }
  597.         
  598.         //    Set the movie box into middle of window.
  599.         SetMovieGWorld((**myWinfo).theMovie, (CGrafPtr) frontWindow, 0);
  600.         GetMovieBox((**myWinfo).theMovie, &movieBounds);
  601.         OffsetRect(&movieBounds, -movieBounds.left, -movieBounds.top);
  602.         SetMovieBox((**myWinfo).theMovie, &movieBounds);
  603.         xoffset = (frontWindow->portRect.right - frontWindow->portRect.left
  604.                      - movieBounds.right + movieBounds.left) / 2;
  605.         yoffset = (frontWindow->portRect.bottom - frontWindow->portRect.top
  606.                      - movieBounds.bottom + movieBounds.top) / 2;
  607.         OffsetRect(&movieBounds, xoffset, yoffset);
  608.         (**myWinfo).theMC = NewMovieController((**myWinfo).theMovie, &movieBounds, mcTopLeftMovie);
  609.     
  610.         //    Tell the controller to attach a movie’s CLUT to the window as appropriate.
  611.         MCDoAction((**myWinfo).theMC, mcActionGetFlags, &controllerFlags);
  612.         MCDoAction((**myWinfo).theMC, mcActionSetFlags, (void *)(controllerFlags | mcFlagsUseWindowPalette));
  613.     
  614.         //    Allow the controller to accept keyboard events.
  615.         MCDoAction((**myWinfo).theMC, mcActionSetKeysEnabled, (void *)true);
  616.     }    
  617. }
  618.  
  619. //--------------------------------------------------------------------------
  620.  
  621. void getNewMovie(Movie *theMovie, Str255 *movieName)
  622. {
  623.     StandardFileReply        reply;
  624.     SFTypeList                types;
  625.     short                    refNum, resId;
  626.     
  627.     *theMovie = nil;
  628.     
  629.     types[0] = 'MooV';
  630.     StandardGetFilePreview(nil, 1, types, &reply);
  631.     if (!reply.sfGood) return;
  632.     
  633.     //    Read movie atom of source movie.
  634.     if (OpenMovieFile(&reply.sfFile, &refNum, fsRdPerm)) {
  635.         SysBeep(50);
  636.         return;
  637.     }
  638.     resId = 0;
  639.     (*movieName)[0] = 0;
  640.     if (NewMovieFromFile(theMovie, refNum, &resId, *movieName, 0, (Boolean *) 0)) {
  641.         SysBeep(50);
  642.         *theMovie = nil;
  643.         return;
  644.     }
  645.     if ((*movieName)[0] == 0)
  646.         BlockMove(reply.sfFile.name, *movieName, reply.sfFile.name[0]+1);
  647.     CloseMovieFile(refNum);
  648. }
  649.  
  650. void Mac_AddMovieResAtom(short *docRefNum, FSSpec *docFSSpec)
  651. {
  652.     Movie                    theMovie;
  653.     Str255                    movieName;
  654.     short                    resId;
  655.  
  656.     getNewMovie(&theMovie, &movieName);    
  657.     if (theMovie != nil) {
  658.         resId = 0;
  659.         AddMovieResource(theMovie, *docRefNum, &resId, movieName);
  660.         DisposeMovie(theMovie);
  661.     }
  662. }
  663.  
  664. void Mac_AddMovieAll(short *docRefNum, FSSpec *docFSSpec)
  665. {
  666.     Movie                    theMovie;
  667.     Str255                    movieName;
  668.  
  669.     getNewMovie(&theMovie, &movieName);    
  670.     if (theMovie != nil) {
  671.         CloseMovieFile(*docRefNum);
  672.         BetterFlattenMovie(theMovie, 0, docFSSpec, 'WnG1', smSystemScript, 0, nil, movieName);
  673.         OpenMovieFile(docFSSpec, docRefNum, fsRdWrPerm);
  674.         DisposeMovie(theMovie);
  675.     }
  676. }
  677.  
  678. void Cross_AddMovieAll(short *docRefNum, FSSpec *docFSSpec)
  679. {
  680.     Movie                    theMovie;
  681.     Str255                    movieName;
  682.  
  683.     getNewMovie(&theMovie, &movieName);    
  684.     if (theMovie != nil) {
  685.         CloseMovieFile(*docRefNum);
  686.         BetterFlattenMovieData(theMovie, flattenAddMovieToDataFork, docFSSpec, 'WnG1', smSystemScript, 0);
  687.         OpenMovieFile(docFSSpec, docRefNum, fsRdWrPerm);
  688.         DisposeMovie(theMovie);
  689.     }
  690. }
  691.  
  692. void Both_AddMovieAll(short *docRefNum, FSSpec *docFSSpec)
  693. {
  694.     Movie                    theMovie;
  695.     Str255                    movieName;
  696.  
  697.     getNewMovie(&theMovie, &movieName);    
  698.     if (theMovie != nil) {
  699.         CloseMovieFile(*docRefNum);
  700.         BetterFlattenMovie(theMovie, flattenAddMovieToDataFork, docFSSpec, 'WnG1', smSystemScript, 0, nil, movieName);
  701.         OpenMovieFile(docFSSpec, docRefNum, fsRdWrPerm);
  702.         DisposeMovie(theMovie);
  703.     }
  704. }
  705.